#include<stdio.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>

int main(int argc,char *argv[])
{
    if(argc!=3)
    {
        printf("error");
        return -1;
    }
    int fd_source,fd_target;
    fd_source=open(argv[1],O_RDONLY);
    fd_target=creat(argv[2],0777);
    if(fd_source==-1||fd_target==-1)
    {
        printf("error");
        return -1;
    }
    char temp;
    int i=read(fd_source,&temp,1);
    if(i==-1)
    {
        printf("error");
        return -1;
    }
    while(i)
    {
        int j=write(fd_target,&temp,1);
        if(j==-1)
        {
            printf("error");
            return -1;
        }
        i=read(fd_source,&temp,1);
    }
    close(fd_source);
    close(fd_target);
    return 0;
}
